home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 13.3 KB | 447 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Shapes.h
- // Release Version: $ 1.0d1 $
- //
- // Author: Henri Lamiraux
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef SHAPES_H
- #define SHAPES_H
-
- #ifndef DRAWFRAME_H
- #include "DrawFrame.h"
- #endif
-
- #ifndef DRAWPROXY_H
- #include "DrawProxy.h"
- #endif
-
- // ----- Graphic Includes -----
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWARCSHP_H
- #include "FWArcShp.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _PLFMDEF_
- #include <PlfmDef.h>
- #endif
-
- // ----- Mac Includes -----
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- //==============================================================================
- // Forward Declarations
- //==============================================================================
-
- class FW_CEmbeddingFrame;
- class XMPFrame;
- class XMPShape;
- class CDrawPart;
- class CDrawPublishLink;
- class CDrawSubscribLink;
-
- //==============================================================================
- // Constants
- //==============================================================================
-
- enum ShapeType {
- kLineShape = 1,
- kRectShape = 2,
- kOvalShape = 3,
- kRRectShape = 4,
- kProxyShape = 5
- };
-
- const unsigned short kFrameOnly = 1;
- const unsigned short kFillOnly = 2;
- const unsigned short kFrameFill = 3;
-
- //==============================================================================
- // class CBaseShape
- //==============================================================================
-
- class CBaseShape
- {
- public:
- virtual ~CBaseShape();
-
- virtual void Removed();
-
- // ----- Drawing -----
- virtual void DrawShape(FW_CGraphicContext* gc) = 0;
- void DrawShapeHandles(FW_CFacet* facet, FW_Boolean turnOn);
- void DrawHandle(short whichHandle);
-
- // ----- Shape setting -----
- virtual void SetShapeProperties(FW_ShapeFills shapeFills, FW_CInk ink, FW_CStyle style);
- virtual void RenderShape(FW_CGraphicContext* gc);
- virtual XMPCoordinate GetPenSize() const;
-
- // ----- Selection -----
- virtual FW_Boolean HitTest(FW_CGraphicContext* gc, const FW_CPoint& mouse, XMPEventData event) const = 0;
- FW_Boolean InSelectionRect(const FW_CRect& rect) const;
-
- short WhichHandle(FW_CFacet* facet, const FW_CPoint& mouse) const;
-
- void CalcHandleRect(short whichHandle, FW_CRect* handleRect) const;
-
- virtual void SelectShape(FW_Boolean state);
- FW_Boolean IsSelected() const
- {return fSelected;}
-
- // ----- Creation -----
- FW_Boolean Track(FW_CGraphicContext* gc, FW_CStyle trackStyle, const FW_CPoint& anchorPoint, XMPEventData event);
- virtual void TrackFeedback(FW_CGraphicContext* gc, const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint, FW_Boolean erase);
- virtual void SetShapeGeometry(const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint) = 0;
-
- // ----- Drag -----
- virtual void OffsetShape(XMPCoordinate xDelta, XMPCoordinate yDelta) = 0;
-
- // ----- Resize -----
- virtual void ResizeFeedback(FW_CGraphicContext* gc, FW_CInk ink, FW_CStyle style, const FW_CRect& originalRect, const FW_CRect& mapRect) = 0;
- virtual void GetHandleCenter(short whichHandle, FW_CPoint* center) const = 0;
- virtual void MapShape(const FW_CRect& srcRect, const FW_CRect& dstRect) = 0;
-
- virtual void GetUpdateShape(XMPShape *updateShape) const = 0;
- virtual void GetDragRgn(FW_CGraphicContext* gc, FW_PlatformRegion dragRgn) = 0;
- virtual XMPShape* GetClipShape(FW_CGraphicContext* gc) = 0;
- virtual FW_CRect GetBoundingBox() const = 0;
-
- // ----- z-Order -----
- virtual void MovedAfter(CBaseShape* shape);
- virtual void MovedBefore(CBaseShape* shape);
- virtual void MovedFirst();
- virtual void MovedLast();
-
- // ----- Persistence -----
- virtual void Flatten(XMPStorageUnit* storage);
- virtual void Unflatten(CDrawPart* drawPart, XMPStorageUnit* storage);
- virtual void CloneTo(XMPStorageUnit* storageUnit, FW_CFrame* commandFrame, XMPCloneKind cloneKind);
- virtual void CloneFrom(CDrawPart* drawPart, XMPStorageUnit* storage, XMPCloneKind cloneKind);
-
- // ----- Cache -----
- void ClearCache();
-
- // ----- Linking -----
- void SetPublishLink(CDrawPublishLink *publishLink)
- {fPublishLink = publishLink;}
- CDrawPublishLink* GetPublishLink() const
- {return fPublishLink;}
- FW_Boolean IsPublished() const
- {return fPublishLink != NULL;}
-
- void SetSubscribLink(CDrawSubscribLink *subscribLink)
- {fSubscribLink = subscribLink;}
- CDrawSubscribLink* GetSubscribLink() const
- {return fSubscribLink;}
- FW_Boolean IsSubscribed() const
- {return fSubscribLink != NULL;}
-
- // ----- Getters/Setters -----
- virtual FW_Boolean SetFrozen(FW_Boolean state);
- virtual FW_Boolean IsFrozen() const;
-
- void SetPenStyle(FW_CStyle penStyle);
- void SetBrushStyle(FW_CStyle brushStyle)
- {fBrushStyle = brushStyle;}
- void SetPenInk(FW_CInk penInk)
- {fPenInk = penInk;}
- void SetBrushInk(FW_CInk brushInk)
- {fBrushInk = brushInk;}
-
- FW_CStyle GetPenStyle()
- {return fPenStyle;}
- FW_CStyle GetBrushStyle()
- {return fBrushStyle;}
- FW_CInk GetPenInk()
- {return fPenInk;}
- FW_CInk GetBrushInk()
- {return fBrushInk;}
-
- FW_Boolean HasFillStyle() const
- {return (fFrameFill & kFillOnly) != 0;}
- FW_Boolean FillOnly() const
- {return fFrameFill == kFillOnly;}
- FW_Boolean HasFrameStyle() const
- {return (fFrameFill & kFrameOnly) != 0;}
- FW_Boolean FrameOnly() const
- {return fFrameFill == kFrameOnly;}
- FW_Boolean HasFrameAndFillStyle() const
- {return (fFrameFill == kFrameFill);}
-
- void SetFrameFillStyle(unsigned short style);
- unsigned short GetFrameFillStyle() const
- {return fFrameFill;}
-
- short GetNumberOfHandles() const
- {return fNumberOfHandles;}
- ShapeType GetShapeType() const
- {return (ShapeType)fShapeType;}
- protected:
- CBaseShape(short numberOfHandles, unsigned short shapeType);
-
- protected:
- XMPShape* fClipShape;
- FW_CShape fBaseShape;
-
- private:
- unsigned short fShapeType;
-
- FW_Boolean fSelected;
- short fNumberOfHandles;
- CDrawPublishLink* fPublishLink;
- CDrawSubscribLink* fSubscribLink;
-
- FW_CInk fPenInk;
- FW_CInk fBrushInk;
- FW_CStyle fPenStyle;
- FW_CStyle fBrushStyle;
-
- unsigned short fFrameFill;
-
- };
-
- //==============================================================================
- // class CLineShape
- //==============================================================================
-
- class CLineShape : public CBaseShape
- {
- public:
- CLineShape();
- virtual ~CLineShape();
-
- // ----- Geometry
- virtual void SetShapeGeometry(const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint);
- virtual void GetUpdateShape(XMPShape *updateShape) const;
- virtual void GetDragRgn(FW_CGraphicContext* gc, FW_PlatformRegion dragRgn);
- virtual XMPShape* GetClipShape(FW_CGraphicContext* gc);
- virtual FW_CRect GetBoundingBox() const;
-
- FW_CPoint GetLineStart() const
- {return fShape->GetLineStart();}
- FW_CPoint GetLineEnd() const
- {return fShape->GetLineEnd();}
-
- // ----- Selection
- virtual FW_Boolean HitTest(FW_CGraphicContext* gc, const FW_CPoint& mouse, XMPEventData event) const;
-
- // ----- Dragging
- virtual void OffsetShape(XMPCoordinate xDelta, XMPCoordinate yDelta);
-
- // ----- Resize
- virtual void ResizeFeedback(FW_CGraphicContext* gc, FW_CInk ink, FW_CStyle style, const FW_CRect& originalRect, const FW_CRect& mapRect);
- virtual void GetHandleCenter(short whichHandle, FW_CPoint* center) const;
- virtual void MapShape(const FW_CRect& srcRect, const FW_CRect& dstRect);
-
- // ----- Drawing
- virtual void DrawShape(FW_CGraphicContext* gc);
-
- // ----- Persistence
- virtual void Flatten(XMPStorageUnit* storage);
- virtual void Unflatten(CDrawPart* drawPart, XMPStorageUnit* storage);
-
- private:
- void OutlineShape(FW_CGraphicContext* gc, FW_CInk ink, FW_CStyle style,
- const FW_CPoint& pt1, const FW_CPoint& pt2);
-
- private:
- FW_CLineShape fShape;
- };
-
- //==============================================================================
- // class CBoundedShape
- //==============================================================================
-
- class CBoundedShape : public CBaseShape
- {
- public:
- virtual ~CBoundedShape();
-
- // ----- Drawing
- virtual void DrawShape(FW_CGraphicContext* gc);
-
- // ----- Geometry
- virtual void SetShapeGeometry(const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint);
- virtual void GetUpdateShape(XMPShape *updateShape) const;
- virtual void GetDragRgn(FW_CGraphicContext* gc, FW_PlatformRegion dragRgn);
- virtual XMPShape* GetClipShape(FW_CGraphicContext* gc);
- virtual void SetBoundingBox(const FW_CRect& bounds) = 0;
-
- // ----- Hit Test
- virtual FW_Boolean HitTest(FW_CGraphicContext* gc, const FW_CPoint& mouse, XMPEventData event) const;
-
- // ----- Dragging
- virtual void OffsetShape(XMPCoordinate xDelta, XMPCoordinate yDelta);
-
- // ----- Resize
- virtual void ResizeFeedback(FW_CGraphicContext* gc, FW_CInk ink, FW_CStyle style, const FW_CRect& originalRect, const FW_CRect& mapRect);
- virtual void GetHandleCenter(short whichHandle, FW_CPoint* center) const;
- virtual void MapShape(const FW_CRect& srcRect, const FW_CRect& dstRect);
-
- // ----- Persistence
- virtual void Flatten(XMPStorageUnit* storage);
- virtual void Unflatten(CDrawPart* drawPart, XMPStorageUnit* storage);
-
- protected:
- CBoundedShape(unsigned short shapeType);
-
- private:
- virtual void OutlineShape(FW_CGraphicContext* gc, FW_CInk ink, FW_CStyle style, const FW_CRect& rect) = 0;
- void CalcRect(const FW_CPoint& anchorPoint, const FW_CPoint& endPoint, FW_CRect* rect);
-
- private:
- FW_CRect fRect;
- };
-
- //==============================================================================
- // class CRectShape
- //==============================================================================
-
- class CRectShape : public CBoundedShape
- {
- public:
- CRectShape();
- virtual ~CRectShape();
-
- // ----- Geometry
- virtual FW_CRect GetBoundingBox() const;
- virtual void SetBoundingBox(const FW_CRect& bounds);
-
- protected:
- CRectShape(unsigned short shapeType);
-
- private:
- virtual void OutlineShape(FW_CGraphicContext* gc, FW_CInk ink, FW_CStyle style, const FW_CRect& rect);
-
- private:
- FW_CRectShape fShape;
- };
-
- //==============================================================================
- // class COvalShape
- //==============================================================================
-
- class COvalShape : public CBoundedShape
- {
- public:
- COvalShape();
- virtual ~COvalShape();
-
- // ----- Geometry
- virtual FW_CRect GetBoundingBox() const;
- virtual void SetBoundingBox(const FW_CRect& bounds);
-
- // ----- Selection
- virtual FW_Boolean HitTest(FW_CGraphicContext* gc, const FW_CPoint& mouse, XMPEventData event) const;
-
- private:
- virtual void OutlineShape(FW_CGraphicContext* gc, FW_CInk ink, FW_CStyle style, const FW_CRect& rect);
-
- private:
- FW_COvalShape fShape;
- };
-
- //==============================================================================
- // class CRoundRectShape
- //==============================================================================
-
- class CRoundRectShape : public CBoundedShape
- {
- public:
- CRoundRectShape();
- virtual ~CRoundRectShape();
-
- // ----- Geometry
- virtual FW_CRect GetBoundingBox() const;
- virtual void SetBoundingBox(const FW_CRect& bounds);
-
- virtual void SetShapeGeometry(const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint);
-
- private:
- virtual void OutlineShape(FW_CGraphicContext* gc, FW_CInk ink, FW_CStyle style, const FW_CRect& rect);
-
- private:
- FW_CRoundRectShape fShape;
- };
-
- //==============================================================================
- // class CProxyShape
- //==============================================================================
-
- class CProxyShape : public CRectShape
- {
- public:
- CProxyShape(const FW_CRect& rect);
- CProxyShape();
- virtual ~CProxyShape();
- virtual void Removed();
-
- virtual void DrawShape(FW_CGraphicContext* gc);
-
- virtual FW_Boolean HitTest(FW_CGraphicContext* gc, const FW_CPoint& mouse, XMPEventData event) const;
-
- virtual void OffsetShape(XMPCoordinate xDelta, XMPCoordinate yDelta);
- virtual void MapShape(const FW_CRect& srcRect, const FW_CRect& dstRect);
-
- virtual void SelectShape(FW_Boolean state);
-
- void ProxyShapeChanged(const FW_CRect& rect);
-
- CDrawProxyRun* GetProxyRun() const
- {return fProxyRun;}
- void SetProxyRun(CDrawProxyRun* proxyRun)
- {fProxyRun = proxyRun;}
-
- // ----- Persistence
- virtual void Flatten(XMPStorageUnit* storage);
- virtual void Unflatten(CDrawPart* drawPart, XMPStorageUnit* storage);
- virtual void CloneTo(XMPStorageUnit* storageUnit,
- FW_CFrame* commandFrame,
- XMPCloneKind cloneKind);
- virtual void CloneFrom(CDrawPart* drawPart,
- XMPStorageUnit* storage,
- XMPCloneKind cloneKind);
-
- // ----- z-Order -----
- virtual void MovedAfter(CBaseShape* shape);
- virtual void MovedBefore(CBaseShape* shape);
- virtual void MovedFirst();
- virtual void MovedLast();
-
- // ----- Frozen -----
- virtual FW_Boolean SetFrozen(FW_Boolean state);
- virtual FW_Boolean IsFrozen() const;
-
- private:
- CDrawProxyRun *fProxyRun;
- FW_Boolean fFrozen;
-
- };
- #endif